package com.mrd.gtimpframe.service.impl;

import com.mrd.gtimpframe.entity.AgentRef;
import com.mrd.gtimpframe.repository.AgentRefMapper;
import com.mrd.gtimpframe.service.AgentRefService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;

@Service
public class AgentRefServiceImpl implements AgentRefService {
    @Resource
    private AgentRefMapper agentRefMapper;

    @Override
    public int deleteByPrimaryKey(Object id) {
        return agentRefMapper.deleteByPrimaryKey((String) id);
    }

    @Override
    @Transactional
    public int insert(Object o) {
        return agentRefMapper.insert((AgentRef) o);
    }

    @Override
    @Transactional
    public int insertSelective(Object o) {
        return agentRefMapper.insertSelective((AgentRef) o);
    }

    @Override
    public Object selectByPrimaryKey(Object id) {
        return agentRefMapper.selectByPrimaryKey((String) id);
    }

    @Override
    public int updateByPrimaryKeySelective(Object o) {
        return agentRefMapper.updateByPrimaryKeySelective((AgentRef) o);
    }

    @Override
    public int updateByPrimaryKey(Object o) {
        return agentRefMapper.updateByPrimaryKey((AgentRef) o);
    }

    /**
     * 根据委托关系查询委托关系，并且查询客户公司信息
     * @author han
     * @param agentRefId 委托关系主键
     * @return
     */
    public AgentRef selAgentRefAndRecessiveCom(String agentRefId){
        return agentRefMapper.selAgentRefAndRecessiveCom(agentRefId);
    }

    /**
     * 根据代理公司id和被代理公司查询关系
     */
    @Override
    public AgentRef getAgentRef(String agentComId, String comInfoId) {
        return agentRefMapper.selectByAgentAndComId(agentComId,comInfoId);
    }
}
